package cn.hf.mychat.teach.controller;

import cn.hf.mychat.config.Result;
import cn.hf.mychat.entity.test.TestEntity;
import cn.hf.mychat.teach.service.TeachService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/wk")
@RequiredArgsConstructor
public class TeachController {
    @Autowired
    private TeachService teachService;

    @GetMapping("date")
    public ResponseEntity getDate() {
        Map<String, Object> map = new HashMap<>();
        map.put("1", "wwww");
        map.put("2", "dddd");
        TestEntity build = TestEntity.builder().name("来啦").password("你好").build();
        map.put("用户", build);
        return ResponseEntity.ok(new Result<>(map));
    }

    @GetMapping("send")
    public ResponseEntity getSentMail() {
        Map<String, Object> map = new HashMap<>();
        if (teachService.sendMail()) {
            map.put("200", "成功");
        } else {
            map.put("300", "执行失败");
        }
        return ResponseEntity.ok(new Result<>(map));
    }

}
